# !/usr/bin/python3
# -*- coding: utf-8 -*-

"""
远程调用管理器类
----------------------------------------------------
@Project :   xinhou-openai-framework
@File    :   OpenAiEmbeddingManager.py
@Contact :   sp_hrz@qq.com

@Modify Time      @Author    @Version    @Desciption
------------      -------    --------    -----------
2023/04/16 22:04  peng.shen   v1.0.0     None
"""
from common.entity.User import User
from xinhou_openai_framework.core.decorator.HttpClientDecorator import http_client
from xinhou_openai_framework.core.remote.manager.BaseManager import BaseManagerImpl


class OpenAiEmbeddingRemoter(BaseManagerImpl[User]):
    """
    OpenAI 远程服务类，用于调用远程服务。
    """

    @staticmethod
    @http_client("http://openai-admin.xinhou.com", path="/health", method="GET")
    def health(response_data, **kwargs):
        """
        健康检查函数。

        Args:
            response_data (dict): 响应数据。
            **kwargs: 关键字参数。

        Returns:
            None
        """
        if response_data:
            # 在这里处理业务逻辑，可以通过 res_data 获取响应数据
            print("Received response data:", response_data)
        else:
            print("No response data received.")

    @staticmethod
    @http_client("http://openai-admin.xinhou.com", path="/test/summary/callback", json_data={
        "summary_process_key": "1",
        "summary_process_result": "测试"
    }, headers={
        "tenant_id": '888888',
        "classify_type": 'role',
        "classify_id": '888888',
        "platform_code": 'pt'
    }, method="POST")
    def test_summary_callback(response_data, **kwargs):
        """
        健康检查函数。

        Args:
            response_data (dict): 响应数据。
            **kwargs: 关键字参数。

        Returns:
            None
        """
        if response_data:
            # 在这里处理业务逻辑，可以通过 res_data 获取响应数据
            print("Received response data:", response_data)
        else:
            print("No response data received.")


if __name__ == "__main__":
    # 调用方式默认使用@http_client注解时通过header 和json_data等参数设置
    OpenAiEmbeddingRemoter.health()

    # 调用方式二
    OpenAiEmbeddingRemoter.test_summary_callback(json_data={
        "summary_process_key": "2",
        "summary_process_result": "测试"
    }, headers={
        "tenant_id": '888888',
        "classify_type": 'role',
        "classify_id": '888888',
        "platform_code": 'pt'
    }, method="POST")